#!/usr/bin/python
"""Based on http://pythonhosted.org/Pyro/6-eventserver.htm

NO, I WILL TRY WITHOUT ANY COMPLICATIONS FIRST

This one passes the event on as a Qt signal. The advantage is that Qt queues the
signals.

References:


"""
from Pyro.EventService.Clients import Subscriber
import PyQt4 as QtCore
from PyQt4 import *
import sys
import threading

class QuoteSubscriber(Subscriber):
    def __init__(self):
        Subscriber.__init__(self)
        self.subscribe("Quote")
        
    def event(self, event):
        print "Got a Quote: %s=%f" % (event.msg)


class SubscriberRunner(threading.Thread, QObject):
    """Thread class to run the quote subscriber.
    
    Subscriber needs to run in a thread, because the listen() method is blocking.
    
    """
    
    ## State variables
    
    sub = None
    bOn = False

    def run(self):
        self.bOn = True
        self.sub = QuoteSubscriber()
        self.sub.listen()
        
        
    def Finish(self):
        if self.bOn:
            self.sub.abort()


app = QtCore.QCoreApplication(sys.argv)
sr = SubscriberRunner()
app.connect(sr, QtCore.SIGNAL("
hello = Hello("Hello World!")
sys.exit(app.exec_())
        #self.emit(Qt.SIGNAL("geometryChanged()"))
